package top.bulk.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import top.bulk.demo.interceptor.BulkInterceptor1;
import top.bulk.demo.interceptor.BulkInterceptor2;

/**
 * @author 散装java
 * @version 1.0.0
 * @date 2022-11-13
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Bean
    public BulkInterceptor1 bulkInterceptor1() {
        return new BulkInterceptor1();
    }

    @Bean
    public BulkInterceptor2 bulkInterceptor2() {
        return new BulkInterceptor2();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截的路径
        registry
                .addInterceptor(bulkInterceptor1())
                .addPathPatterns("/**")
                .order(1);
        registry
                .addInterceptor(bulkInterceptor2())
                .addPathPatterns("/**")
                .order(2);


    }
}
